/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.entity;

import java.util.ArrayList;
import java.util.Collection;





import org.dom4j.Element;
import org.jackysoft.bean.define.EntitySchemas;

/**
 * DOCUMENT ME!
 */



public class JoinNode extends AbstractNode {
	// ~ Instance fields
	// ////////////////////////////////////////////////////////

	/**
	 * 
	 */
	private static final long serialVersionUID = 6374557114756627847L;
	protected ConditionsNode conditions;
	protected ResultNode result;

	
	private Collection<OsStep> joinSteps = new ArrayList<OsStep>();
	
	// ~ Constructors
	// ///////////////////////////////////////////////////////////

	/**
     * 
     */
	public JoinNode() {
		super();
	}

	/**
     * 
     */
	public JoinNode(Element root) {
		super(root);
	}

	
	public JoinNode(Collection<OsStep> joinSteps){
		this.joinSteps = joinSteps;
	}
	@Override
	public Element asElement() {
		Element root = elementof("join");
		attr(root, "id", id);
		addchild(root, this.conditions);
		addchild(root, this.result);
		return root;
	}

	// ~ Methods
	// ////////////////////////////////////////////////////////////////

	
	
	public ConditionsNode getConditions() {
		return conditions;
	}

	
	
	public ResultNode getResult() {
		return result;
	}

	@Override
	protected void init(Element root) {

		this.result = childof(root, "unconditional-result", ResultNode.class);
		this.conditions = childof(root, "conditions", ConditionsNode.class);
	}

	public void setConditions(ConditionsNode conditions) {
		this.conditions = conditions;
	}

	public void setResult(ResultNode result) {
		this.result = result;
	}

	@Override
	public String tagName() {
		// TODO Auto-generated method stub
		return "join";
	}

	public Collection<OsStep> getJoinSteps() {
		return joinSteps;
	}

	public void setJoinSteps(Collection<OsStep> joinSteps) {
		this.joinSteps = joinSteps;
	}
}
